<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="java,kafka,springboot,storm," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="前言本篇文章主要介绍的是SpringBoot整合kafka和storm以及在这过程遇到的一些问题和解决方案。 kafka和storm的相关知识如果你对kafka和storm熟悉的话，这一段可以直接跳过！如果不熟，也可以看看我之前写的博客。一些相关博客如下。 kafka 和 storm的环境安装 地址:http://www.panchengming.com/2018/01/26/pancm70/">
<meta name="keywords" content="java,kafka,springboot,storm">
<meta property="og:type" content="article">
<meta property="og:title" content="SpringBoot整合Kafka和Storm">
<meta property="og:url" content="http://yoursite.com/2018/05/10/pancm83/index.html">
<meta property="og:site_name" content="虚无境的博客">
<meta property="og:description" content="前言本篇文章主要介绍的是SpringBoot整合kafka和storm以及在这过程遇到的一些问题和解决方案。 kafka和storm的相关知识如果你对kafka和storm熟悉的话，这一段可以直接跳过！如果不熟，也可以看看我之前写的博客。一些相关博客如下。 kafka 和 storm的环境安装 地址:http://www.panchengming.com/2018/01/26/pancm70/">
<meta property="og:image" content="https://img-blog.csdn.net/20180510194020257?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FhendzeHBjbQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70">
<meta property="og:updated_time" content="2018-05-10T12:34:58.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="SpringBoot整合Kafka和Storm">
<meta name="twitter:description" content="前言本篇文章主要介绍的是SpringBoot整合kafka和storm以及在这过程遇到的一些问题和解决方案。 kafka和storm的相关知识如果你对kafka和storm熟悉的话，这一段可以直接跳过！如果不熟，也可以看看我之前写的博客。一些相关博客如下。 kafka 和 storm的环境安装 地址:http://www.panchengming.com/2018/01/26/pancm70/">
<meta name="twitter:image" content="https://img-blog.csdn.net/20180510194020257?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FhendzeHBjbQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/05/10/pancm83/"/>






  <title>SpringBoot整合Kafka和Storm | 虚无境的博客</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?39c177d10f6e05ddfa113e02139b9c1c";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>










</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">虚无境的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/05/10/pancm83/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="虚无境">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/xuwujing.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="虚无境的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">SpringBoot整合Kafka和Storm</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-05-10T20:32:00+08:00">
                2018-05-10
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/java/" itemprop="url" rel="index">
                    <span itemprop="name">java</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <script src="\assets\js\APlayer.min.js"> </script><h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>本篇文章主要介绍的是SpringBoot整合kafka和storm以及在这过程遇到的一些问题和解决方案。</p>
<h2 id="kafka和storm的相关知识"><a href="#kafka和storm的相关知识" class="headerlink" title="kafka和storm的相关知识"></a>kafka和storm的相关知识</h2><p>如果你对<strong>kafka</strong>和<strong>storm</strong>熟悉的话，这一段可以直接跳过！如果不熟，也可以看看我之前写的博客。一些相关博客如下。</p>
<p><strong>kafka 和 storm的环境安装</strong></p>
<p>地址:<a href="http://www.panchengming.com/2018/01/26/pancm70/" target="_blank" rel="external">http://www.panchengming.com/2018/01/26/pancm70/</a></p>
<p><strong>kafka的相关使用</strong></p>
<p>地址:<a href="http://www.panchengming.com/2018/01/28/pancm71/" target="_blank" rel="external">http://www.panchengming.com/2018/01/28/pancm71/</a><br>      <a href="http://www.panchengming.com/2018/02/08/pancm72/" target="_blank" rel="external">http://www.panchengming.com/2018/02/08/pancm72/</a></p>
<p><strong>storm的相关使用</strong></p>
<p>地址:<a href="http://www.panchengming.com/2018/03/16/pancm75/" target="_blank" rel="external">http://www.panchengming.com/2018/03/16/pancm75/</a></p>
<h2 id="SpringBoot整合kafka和storm"><a href="#SpringBoot整合kafka和storm" class="headerlink" title="SpringBoot整合kafka和storm"></a>SpringBoot整合kafka和storm</h2><h3 id="为什么使用SpringBoot整合kafka和storm"><a href="#为什么使用SpringBoot整合kafka和storm" class="headerlink" title="为什么使用SpringBoot整合kafka和storm"></a>为什么使用SpringBoot整合kafka和storm</h3><p>一般而言，使用kafka整合storm可以应付大多数需求。但是在扩展性上来说，可能就不太好。目前主流的微服务框架SpringCloud是基于SpringBoot的，所以使用SpringBoot对kafka和storm进行整合，可以进行统一配置，扩展性会更好。</p>
<h3 id="使用SpringBoot整合kafka和storm做什么"><a href="#使用SpringBoot整合kafka和storm做什么" class="headerlink" title="使用SpringBoot整合kafka和storm做什么"></a>使用SpringBoot整合kafka和storm做什么</h3><p>一般来说，kafka和storm的整合，使用kafka进行数据的传输，然后使用storm实时的处理kafka中的数据。</p>
<p>在这里我们加入SpringBoot之后，也是做这些，只不过是由SpringBoot对kafka和storm进行统一的管理。</p>
<p>如果还是不好理解的话，可以通过下面这个简单的业务场景了解下:</p>
<blockquote>
<p>在数据库中有一批大量的用户数据，其中这些用户数据中有很多是不需要的，也就是脏数据，我们需要对这些用户数据进行清洗，然后重新存入数据库中，但是要求实时、延时低，并且便于管理。</p>
</blockquote>
<p>所以这里我们就可以使用SpringBoot+kafka+storm来进行相应的开发。</p>
<h3 id="开发准备"><a href="#开发准备" class="headerlink" title="开发准备"></a>开发准备</h3><p>在进行代码开发前，我们要明确开发什么。<br>在上述的业务场景中，需要大量的数据，但是我们这里只是简单的进行开发，也就是写个简单的demo出来，能够简单的实现这些功能，所以我们只需满足如下条件就可以了:</p>
<ol>
<li>提供一个将用户数据写入kafka的接口;</li>
<li>使用storm的spout获取kafka的数据并发送给bolt;</li>
<li>在bolt移除年龄小于10岁的用户的数据，并写入mysql;</li>
</ol>
<p>那么根据上述要求我们进行SpringBoot、kafka和storm的整合。<br>首先需要相应jar包，所以maven的依赖如下:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div><div class="line">120</div><div class="line">121</div><div class="line">122</div><div class="line">123</div><div class="line">124</div><div class="line">125</div><div class="line">126</div><div class="line">127</div><div class="line">128</div><div class="line">129</div><div class="line">130</div><div class="line">131</div><div class="line">132</div><div class="line">133</div><div class="line">134</div><div class="line">135</div><div class="line">136</div><div class="line">137</div><div class="line">138</div><div class="line">139</div><div class="line">140</div><div class="line">141</div><div class="line">142</div><div class="line">143</div><div class="line">144</div><div class="line">145</div><div class="line">146</div></pre></td><td class="code"><pre><div class="line"></div><div class="line">&lt;properties&gt;</div><div class="line">	&lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;</div><div class="line">	&lt;java.version&gt;1.8&lt;/java.version&gt;</div><div class="line">	&lt;springboot.version&gt;1.5.9.RELEASE&lt;/springboot.version&gt;</div><div class="line">	&lt;mybatis-spring-boot&gt;1.2.0&lt;/mybatis-spring-boot&gt;</div><div class="line">	&lt;mysql-connector&gt;5.1.44&lt;/mysql-connector&gt;</div><div class="line">	&lt;slf4j.version&gt;1.7.25&lt;/slf4j.version&gt;</div><div class="line">	&lt;logback.version&gt;1.2.3&lt;/logback.version&gt;</div><div class="line">	&lt;kafka.version&gt;1.0.0&lt;/kafka.version&gt;</div><div class="line">	&lt;storm.version&gt;1.2.1&lt;/storm.version&gt;</div><div class="line">	&lt;fastjson.version&gt;1.2.41&lt;/fastjson.version&gt;</div><div class="line">	&lt;druid&gt;1.1.8&lt;/druid&gt;</div><div class="line">&lt;/properties&gt;</div><div class="line"></div><div class="line"></div><div class="line">&lt;dependencies&gt;</div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;springboot.version&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line">	&lt;!-- Spring Boot Mybatis 依赖 --&gt;</div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;org.mybatis.spring.boot&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;mybatis-spring-boot-starter&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;mybatis-spring-boot&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line">	&lt;!-- MySQL 连接驱动依赖 --&gt;</div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;mysql&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;mysql-connector&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line"></div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;org.slf4j&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;slf4j.version&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line"></div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;logback-classic&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;logback.version&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;logback-core&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;logback.version&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line"></div><div class="line">	&lt;!-- kafka --&gt;</div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;kafka_2.12&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;kafka.version&#125;&lt;/version&gt;</div><div class="line">		&lt;exclusions&gt;</div><div class="line">			&lt;exclusion&gt;</div><div class="line">				&lt;groupId&gt;org.apache.zookeeper&lt;/groupId&gt;</div><div class="line">				&lt;artifactId&gt;zookeeper&lt;/artifactId&gt;</div><div class="line">			&lt;/exclusion&gt;</div><div class="line">			&lt;exclusion&gt;</div><div class="line">				&lt;groupId&gt;org.slf4j&lt;/groupId&gt;</div><div class="line">				&lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;</div><div class="line">			&lt;/exclusion&gt;</div><div class="line">			&lt;exclusion&gt;</div><div class="line">				&lt;groupId&gt;log4j&lt;/groupId&gt;</div><div class="line">				&lt;artifactId&gt;log4j&lt;/artifactId&gt;</div><div class="line">			&lt;/exclusion&gt;</div><div class="line">		&lt;/exclusions&gt;</div><div class="line">		&lt;scope&gt;provided&lt;/scope&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line"></div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;kafka-clients&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;kafka.version&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;kafka-streams&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;kafka.version&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line"></div><div class="line">	&lt;!--storm相关jar --&gt;</div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;org.apache.storm&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;storm-core&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;storm.version&#125;&lt;/version&gt;</div><div class="line">		&lt;!--排除相关依赖 --&gt;</div><div class="line">		&lt;exclusions&gt;</div><div class="line">			&lt;exclusion&gt;</div><div class="line">				&lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;</div><div class="line">				&lt;artifactId&gt;log4j-slf4j-impl&lt;/artifactId&gt;</div><div class="line">			&lt;/exclusion&gt;</div><div class="line">			&lt;exclusion&gt;</div><div class="line">				&lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;</div><div class="line">				&lt;artifactId&gt;log4j-1.2-api&lt;/artifactId&gt;</div><div class="line">			&lt;/exclusion&gt;</div><div class="line">			&lt;exclusion&gt;</div><div class="line">				&lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;</div><div class="line">				&lt;artifactId&gt;log4j-web&lt;/artifactId&gt;</div><div class="line">			&lt;/exclusion&gt;</div><div class="line">			&lt;exclusion&gt;</div><div class="line">				&lt;groupId&gt;org.slf4j&lt;/groupId&gt;</div><div class="line">				&lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;</div><div class="line">			&lt;/exclusion&gt;</div><div class="line">			&lt;exclusion&gt;</div><div class="line">				&lt;artifactId&gt;ring-cors&lt;/artifactId&gt;</div><div class="line">				&lt;groupId&gt;ring-cors&lt;/groupId&gt;</div><div class="line">			&lt;/exclusion&gt;</div><div class="line">		&lt;/exclusions&gt;</div><div class="line">		&lt;scope&gt;provided&lt;/scope&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;org.apache.storm&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;storm-kafka&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;storm.version&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line"></div><div class="line">	&lt;!--fastjson 相关jar --&gt;</div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;com.alibaba&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;fastjson&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;fastjson.version&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line"></div><div class="line">	&lt;!-- Druid 数据连接池依赖 --&gt;</div><div class="line">	&lt;dependency&gt;</div><div class="line">		&lt;groupId&gt;com.alibaba&lt;/groupId&gt;</div><div class="line">		&lt;artifactId&gt;druid&lt;/artifactId&gt;</div><div class="line">		&lt;version&gt;$&#123;druid&#125;&lt;/version&gt;</div><div class="line">	&lt;/dependency&gt;</div><div class="line">&lt;/dependencies&gt;</div></pre></td></tr></table></figure>
<p>成功添加了相关依赖之后，这里我们再来添加相应的配置。<br>在<strong>application.properties</strong>中添加如下配置:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"></div><div class="line"># log</div><div class="line">logging.config=classpath:logback.xml</div><div class="line"></div><div class="line">## mysql</div><div class="line">spring.datasource.url=jdbc:mysql://localhost:3306/springBoot2?useUnicode=true&amp;characterEncoding=utf8&amp;allowMultiQueries=true</div><div class="line">spring.datasource.username=root</div><div class="line">spring.datasource.password=123456</div><div class="line">spring.datasource.driverClassName=com.mysql.jdbc.Driver</div><div class="line"></div><div class="line"></div><div class="line">## kafka </div><div class="line">kafka.servers = 192.169.0.23\:9092,192.169.0.24\:9092,192.169.0.25\:9092  </div><div class="line">kafka.topicName = USER_TOPIC</div><div class="line">kafka.autoCommit = false</div><div class="line">kafka.maxPollRecords = 100</div><div class="line">kafka.groupId = groupA</div><div class="line">kafka.commitRule = earliest</div></pre></td></tr></table></figure>
<p><strong>注:上述的配置只是一部分，完整的配置可以在我的github中找到。</strong></p>
<p>数据库脚本:</p>
<pre><code>-- springBoot2库的脚本

CREATE TABLE `t_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT &apos;自增id&apos;,
  `name` varchar(10) DEFAULT NULL COMMENT &apos;姓名&apos;,
  `age` int(2) DEFAULT NULL COMMENT &apos;年龄&apos;,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8
</code></pre><p><strong>注:因为这里我们只是简单的模拟一下业务场景，所以只是建立一张简单的表。</strong></p>
<h3 id="代码编写"><a href="#代码编写" class="headerlink" title="代码编写"></a>代码编写</h3><p><strong>说明:这里我只对几个关键的类进行说明，完整的项目工程链接可以在博客底部找到。</strong></p>
<p>在使用SpringBoot整合kafka和storm之前，我们可以先对kfaka和storm的相关代码编写，然后在进行整合。</p>
<p>首先是数据源的获取，也就是使用storm中的spout从kafka中拉取数据。</p>
<p>在之前的storm入门中，讲过storm的运行流程，其中spout是storm获取数据的一个组件，其中我们主要实现<strong>nextTuple</strong>方法，编写从kafka中获取数据的代码就可以在storm启动后进行数据的获取。</p>
<p><strong>spout</strong>类的主要代码如下:</p>
<pre><code>@Override
public void nextTuple() {
    for (;;) {
        try {
            msgList = consumer.poll(100);
            if (null != msgList &amp;&amp; !msgList.isEmpty()) {
                String msg = &quot;&quot;;
                List&lt;User&gt; list=new ArrayList&lt;User&gt;();
                for (ConsumerRecord&lt;String, String&gt; record : msgList) {
                    // 原始数据
                    msg = record.value();
                    if (null == msg || &quot;&quot;.equals(msg.trim())) {
                        continue;
                    }
                    try{
                        list.add(JSON.parseObject(msg, User.class));
                    }catch(Exception e){
                        logger.error(&quot;数据格式不符!数据:{}&quot;,msg);
                        continue;
                    }
                 } 
                logger.info(&quot;Spout发射的数据:&quot;+list);
                //发送到bolt中
                this.collector.emit(new Values(JSON.toJSONString(list)));
                 consumer.commitAsync();
            }else{
                TimeUnit.SECONDS.sleep(3);
                logger.info(&quot;未拉取到数据...&quot;);
            }
        } catch (Exception e) {
            logger.error(&quot;消息队列处理异常!&quot;, e);
            try {
                TimeUnit.SECONDS.sleep(10);
            } catch (InterruptedException e1) {
                logger.error(&quot;暂停失败!&quot;,e1);
            }
        }
    }
}
</code></pre><p><strong>注:如果spout在发送数据的时候发送失败，是会重发的！</strong></p>
<p>上述spout类中主要是将从kafka获取的数据传输传输到bolt中，然后再由bolt类处理该数据，处理成功之后，写入数据库，然后给与sqout响应，避免重发。</p>
<p>bolt类主要处理业务逻辑的方法是<strong>execute</strong>，我们主要实现的方法也是写在这里。需要注意的是这里只用了一个bolt，因此也不用定义Field进行再次的转发。<br>代码的实现类如下:</p>
<pre><code>@Override
    public void execute(Tuple tuple) {
        String msg=tuple.getStringByField(Constants.FIELD);
        try{
            List&lt;User&gt; listUser =JSON.parseArray(msg,User.class);
            //移除age小于10的数据
            if(listUser!=null&amp;&amp;listUser.size()&gt;0){
                Iterator&lt;User&gt; iterator = listUser.iterator();
                 while (iterator.hasNext()) {
                     User user = iterator.next();
                     if (user.getAge()&lt;10) {
                         logger.warn(&quot;Bolt移除的数据:{}&quot;,user);
                         iterator.remove();
                     }
                 }
                if(listUser!=null&amp;&amp;listUser.size()&gt;0){
                    userService.insertBatch(listUser);
                }
            }
        }catch(Exception e){
            logger.error(&quot;Bolt的数据处理失败!数据:{}&quot;,msg,e);
        }
    }
</code></pre><p>编写完了spout和bolt之后，我们再来编写storm的主类。</p>
<p>storm的主类主要是对Topology(拓步)进行提交，提交Topology的时候，需要对spout和bolt进行相应的设置。Topology的运行的模式有两种:</p>
<ol>
<li><p>一种是本地模式，利用本地storm的jar模拟环境进行运行。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">LocalCluster cluster = new LocalCluster();</div><div class="line">cluster.submitTopology(&quot;TopologyApp&quot;, conf,builder.createTopology());</div></pre></td></tr></table></figure>
</li>
<li><p>另一种是远程模式，也就是在storm集群进行运行。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">StormSubmitter.submitTopology(args[0], conf, builder.createTopology());</div></pre></td></tr></table></figure>
</li>
</ol>
<p>这里为了方便，两种方法都编写了，通过主方法的args参数来进行控制。<br><strong>Topology</strong>相关的配置说明在代码中的注释写的很详细了，这里我就不再多说了。<br>代码如下:</p>
<pre><code>public  void runStorm(String[] args) {
  // 定义一个拓扑
  TopologyBuilder builder = new TopologyBuilder();
  // 设置1个Executeor(线程)，默认一个
  builder.setSpout(Constants.KAFKA_SPOUT, new KafkaInsertDataSpout(), 1);
  // shuffleGrouping:表示是随机分组
  // 设置1个Executeor(线程)，和两个task
  builder.setBolt(Constants.INSERT_BOLT, new InsertBolt(), 1).setNumTasks(1).shuffleGrouping(Constants.KAFKA_SPOUT);
  Config conf = new Config();
  //设置一个应答者
  conf.setNumAckers(1);
  //设置一个work
  conf.setNumWorkers(1);
  try {
      // 有参数时，表示向集群提交作业，并把第一个参数当做topology名称
      // 没有参数时，本地提交
      if (args != null &amp;&amp; args.length &gt; 0) { 
          logger.info(&quot;运行远程模式&quot;);
          StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
      } else {
          // 启动本地模式
          logger.info(&quot;运行本地模式&quot;);
          LocalCluster cluster = new LocalCluster();
          cluster.submitTopology(&quot;TopologyApp&quot;, conf, builder.createTopology());
      }
  } catch (Exception e) {
      logger.error(&quot;storm启动失败!程序退出!&quot;,e);
      System.exit(1);
  }
  logger.info(&quot;storm启动成功...&quot;);
  }
</code></pre><p>好了，编写完了kafka和storm相关的代码之后，我们再来进行和SpringBoot的整合!</p>
<p>在进行和SpringBoot整合前，我们先要解决下一下几个问题。</p>
<p>1 在SpringBoot程序中如何提交storm的Topolgy?</p>
<blockquote>
<p>storm是通过提交Topolgy来确定如何启动的，一般使用过运行main方法来启动，但是SpringBoot启动方式一般也是通过main方法启动的。所以应该怎么样解决呢?</p>
</blockquote>
<ul>
<li>解决思路:将storm的Topology写在SpringBoot启动的主类中，随着SpringBoot启动而启动。</li>
<li>实验结果:可以一起启动(按理来说也是可以的)。但是随之而来的是下一个问题，bolt和spout类无法使用spring注解。</li>
</ul>
<p>2 如何让bolt和spout类使用spring注解?</p>
<ul>
<li>解决思路:在了解到spout和bolt类是由nimbus端实例化，然后通过序列化传输到supervisor，再反向序列化，因此无法使用注解，所以这里可以换个思路，既然不能使用注解，那么就动态获取Spring的bean就好了。</li>
<li>实验结果:使用动态获取bean的方法之后，可以成功启动storm了。</li>
</ul>
<p>3.有时启动正常，有时无法启动，动态的bean也无法获取?</p>
<ul>
<li>解决思路:在解决了1、2的问题之后，有时出现问题3，找了很久才找到，是因为之前加入了SpringBoot的热部署，去掉之后就没出现了…。</li>
</ul>
<p>上面的三个问题是我在整合的时候遇到的，其中解决办法在目前看来是可行的，或许其中的问题可能是因为其他的原因导致的，不过目前就这样整合之后，就没出现过其他的问题了。若上述问题和解决办法有不妥之后，欢迎批评指正！</p>
<p>解决了上面的问题之后，我们回到代码这块。<br>其中，程序的入口，也就是主类的代码在进行整合后如下:</p>
<pre><code>@SpringBootApplication
public class Application{

    public static void main(String[] args) {
        // 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件
        ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
        GetSpringBean springBean=new GetSpringBean();
        springBean.setApplicationContext(context);
        TopologyApp app = context.getBean(TopologyApp.class);
        app.runStorm(args);
    }

}
</code></pre><p>动态获取bean的代码如下:</p>
<pre><code>public class GetSpringBean implements ApplicationContextAware{

    private static ApplicationContext context;

    public static Object getBean(String name) {
        return context.getBean(name);
    }

    public static &lt;T&gt; T getBean(Class&lt;T&gt; c) {

        return context.getBean(c);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext)
            throws BeansException {
        if(applicationContext!=null){
            context = applicationContext;
        }
    }

}
</code></pre><p>主要的代码的介绍就到这里了，至于其它的，基本就和以前的一样了。</p>
<h2 id="测试结果"><a href="#测试结果" class="headerlink" title="测试结果"></a>测试结果</h2><p>成功启动程序之后，我们先调用接口新增几条数据到kafka</p>
<p><strong>新增请求:</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">POST http://localhost:8087/api/user</div><div class="line"></div><div class="line">&#123;&quot;name&quot;:&quot;张三&quot;,&quot;age&quot;:20&#125;</div><div class="line">&#123;&quot;name&quot;:&quot;李四&quot;,&quot;age&quot;:10&#125;</div><div class="line">&#123;&quot;name&quot;:&quot;王五&quot;,&quot;age&quot;:5&#125;</div></pre></td></tr></table></figure>
<p>新增成功之后，我们可以使用xshell工具在kafka集群中查看数据。<br>输入:<code>**kafka-console-consumer.sh  --zookeeper master:2181  --topic USER_TOPIC --from-beginning**</code></p>
<p>然后可以看到以下输出结果。</p>
<p>   <img src="https://img-blog.csdn.net/20180510194020257?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FhendzeHBjbQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70" alt="这里写图片描述"></p>
<p>上述也表示了数据成功的写入了kafka。<br>因为是实时的从kafka那数据，我们也可以从控制台查看打印的语句。</p>
<p><strong>控制台输出:</strong></p>
<pre><code>INFO  com.pancm.storm.spout.KafkaInsertDataSpout - Spout发射的数据:[{&quot;age&quot;:5,&quot;name&quot;:&quot;王五&quot;}, {&quot;age&quot;:10,&quot;name&quot;:&quot;李四&quot;}, {&quot;age&quot;:20,&quot;name&quot;:&quot;张三&quot;}]
WARN  com.pancm.storm.bolt.InsertBolt - Bolt移除的数据:{&quot;age&quot;:5,&quot;name&quot;:&quot;王五&quot;}
INFO  com.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited
DEBUG com.pancm.dao.UserDao.insertBatch - ==&gt;  Preparing: insert into t_user (name,age) values (?,?) , (?,?) 
DEBUG com.pancm.dao.UserDao.insertBatch - ==&gt; Parameters: 李四(String), 10(Integer), 张三(String), 20(Integer)
DEBUG com.pancm.dao.UserDao.insertBatch - &lt;==    Updates: 2
INFO  com.pancm.service.impl.UserServiceImpl - 批量新增2条数据成功!
</code></pre><p>可以在控制台成功的看到处理的过程和结果。<br>然后我们也可以通过接口进行数据库所有的数据查询。</p>
<p><strong>查询请求:</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">GET http://localhost:8087/api/user</div></pre></td></tr></table></figure>
<p><strong>返回结果:</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[&#123;&quot;id&quot;:1,&quot;name&quot;:&quot;李四&quot;,&quot;age&quot;:10&#125;,&#123;&quot;id&quot;:2,&quot;name&quot;:&quot;张三&quot;,&quot;age&quot;:20&#125;]</div></pre></td></tr></table></figure>
<p>上述代码中测试返回的结果显然是符合我们预期的。</p>
<h2 id="结语"><a href="#结语" class="headerlink" title="结语"></a>结语</h2><p>关于SpringBoot整合kafka和storm暂时就告一段落了。本篇文章只是简单的介绍这些 相关的使用，在实际的应用可能会更复杂。如果有有更好的想法和建议，欢迎留言进行讨论！<br>SpringBoot整合kafka和storm的工程我放在github上了，如果感觉不错的话请给个star吧。<br>Gihub地址:<a href="https://github.com/xuwujing/springBoot-study" target="_blank" rel="external">https://github.com/xuwujing/springBoot-study</a><br>对了，也有kafka整合storm的工程，也在我的github上。<br>地址:<a href="https://github.com/xuwujing/kafka-study" target="_blank" rel="external">https://github.com/xuwujing/kafka-study</a></p>
<p>到此，本文结束，谢谢阅读。</p>
<p>版权声明:<br>作者：虚无境<br>博客园出处：<a href="http://www.cnblogs.com/xuwujing" target="_blank" rel="external">http://www.cnblogs.com/xuwujing</a><br>CSDN出处：<a href="http://blog.csdn.net/qazwsxpcm" target="_blank" rel="external">http://blog.csdn.net/qazwsxpcm</a>　　　　<br>个人博客出处：<a href="http://www.panchengming.com" target="_blank" rel="external">http://www.panchengming.com</a><br>原创不易，转载请标明出处，谢谢！</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>
     
    <div>
	 +
	  
<div style="text-align:center;color: #ccc;font-size:14px;">
------ 本文结束 ------</div>
<br/>
<div style="border: 1px solid black">
<div style="margin-left:10px">
<span style="font-weight:blod">版权声明</span>
<!-- <img src="/images/xuwujing.png" > -->
<br/>
<p style="font-size: 10px;line-height: 30px"><a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a> by <a href="http://www.panchengming.com/" style="color:#258FC6">ChengMing Pan</a> is licensed under a <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" style="color:#258FC6">Creative Commons BY-NC-ND 4.0 International License</a>.<br/>
由<a href="http://www.panchengming.com/" style="color:#258FC6">虚无境</a>创作并维护的<a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a>博客采用<a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" style="color:#258FC6">创作共用保留署名-非商业-禁止演绎4.0国际许可证</a>。<br/>
本文首发于<a href="http://www.panchengming.com/" style="color:#258FC6">xuwujing's Notes</a> 博客（ <a href="http://www.panchengming.com/" style="color:#258FC6">http://www.panchengming.com/</a> ），版权所有，侵权必究。</p>
</div>
</div>

	
	</div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/java/" rel="tag"># java</a>
          
            <a href="/tags/kafka/" rel="tag"># kafka</a>
          
            <a href="/tags/springboot/" rel="tag"># springboot</a>
          
            <a href="/tags/storm/" rel="tag"># storm</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/05/07/pancm82/" rel="next" title="SpringBoot整合ElasticSearch实现多版本的兼容">
                <i class="fa fa-chevron-left"></i> SpringBoot整合ElasticSearch实现多版本的兼容
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/05/28/pancm84/" rel="prev" title="Java基础知识回顾之五 ----- 多线程">
                Java基础知识回顾之五 ----- 多线程 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/xuwujing.png"
               alt="虚无境" />
          <p class="site-author-name" itemprop="name">虚无境</p>
           
              <p class="site-description motion-element" itemprop="description">The way of the future!</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">136</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">30</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">59</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/xuwujing" target="_blank" title="github">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  github
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://blog.csdn.net/qazwsxpcm?viewmode=list" target="_blank" title="csdn">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  csdn
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://home.cnblogs.com/u/xuwujing/" target="_blank" title="cnblogs">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  cnblogs
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.woainia.site/" title="woainia" target="_blank">woainia</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://cmsblogs.com/" title="chenssy" target="_blank">chenssy</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://italker.imisty.cn" title="xiaowu" target="_blank">xiaowu</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#kafka和storm的相关知识"><span class="nav-number">2.</span> <span class="nav-text">kafka和storm的相关知识</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#SpringBoot整合kafka和storm"><span class="nav-number">3.</span> <span class="nav-text">SpringBoot整合kafka和storm</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#为什么使用SpringBoot整合kafka和storm"><span class="nav-number">3.1.</span> <span class="nav-text">为什么使用SpringBoot整合kafka和storm</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用SpringBoot整合kafka和storm做什么"><span class="nav-number">3.2.</span> <span class="nav-text">使用SpringBoot整合kafka和storm做什么</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#开发准备"><span class="nav-number">3.3.</span> <span class="nav-text">开发准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#代码编写"><span class="nav-number">3.4.</span> <span class="nav-text">代码编写</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#测试结果"><span class="nav-number">4.</span> <span class="nav-text">测试结果</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#结语"><span class="nav-number">5.</span> <span class="nav-text">结语</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">虚无境</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
 | 
本站总访问量<span id="busuanzi_value_site_pv"></span>次
 | 
本站访客数<span id="busuanzi_value_site_uv"></span>人次
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=857896&auto=0&height=66"></iframe>



        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
